import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_test1/constant/Constant.dart';
import 'package:flutter_test1/views/login/login.dart';
import 'package:flutter_test1/views/main/main.dart';
import 'package:flutter_test1/views/webView/webView.dart';
import 'package:flutter_test1/views/welcome/welcome.dart';

void main() {
  runApp(MyApp());
  SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(
    statusBarColor:Colors.blue,
    statusBarIconBrightness: Brightness.light,
  );
  SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      builder: EasyLoading.init(),
      title: Constants.APP_NAME,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      routes: {
        "/":(context) => Welcome()
      },
      onGenerateRoute: (RouteSettings settings){
        String? routeName = settings.name;
        var arguments = settings.arguments;
        //判断这个页面是否需要登录，目前是否是登录状态
        if(1 == 0){//需要登录
          return MaterialPageRoute(builder: (BuildContext context) {
            return LoginPage();
          });
        }else{//不需要登录
          switch(routeName){
            case "MainPage":
              return MaterialPageRoute(builder: (BuildContext context) {
                return MainPage();
              });
            case "WebView":
              return MaterialPageRoute(builder: (BuildContext context) {
                return WebView();
              });
            break;
          }
        }
      }
    );
  }
}
